home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Cream of the Crop 1
/
Cream of the Crop 1.iso
/
PROGRAM
/
CUJ9209.ARJ
/
TEST1.CPP
< prev
next >
Wrap
Text File
|
1980-01-08
|
743b
|
50 lines
#include <iostream.h>
#include "ExH.h"
class Ex1:public Exception {
int a_value;
public:
Ex1(int v) {a_value = v;}
static int ctype() {return 1;}
int type() {return 1;}
int size() {return sizeof(Ex1);}
int getvalue() {return a_value;}
};
void f2(int fail)
{
if(fail) // Throw
ExH::throw(Ex1(10));
cout << "F2 OK\n";
}
void f1(int fail)
{
f2(fail);
}
main()
{
// Try
if(setjmp(ExH::stk++)==0) {
f1(0);
f1(1);
}
//Catch
else if( ExH::lastEx->type() == Ex1::ctype()) {
Ex1& m = *(Ex1*)ExH::lastEx;
cout << "Catching Exception type 1. Value = "
<< m.getvalue() << "\n";
f1(0);
}
else {
cout << "Bad type\n";
unexpected();
}
cout << "Normal End\n";
}